﻿#ifndef MOVEPANEL_H
#define MOVEPANEL_H

#include <QDialog>


QT_BEGIN_NAMESPACE
namespace Ui { class MovePanel; }
QT_END_NAMESPACE

class MovePanel : public QDialog
{
    Q_OBJECT

public:
    MovePanel(QWidget *parent = nullptr);
    ~MovePanel();

signals:
    void doSelected(const QString& codeName);                       //选中了某一块

protected:
    void paintEvent(QPaintEvent*) override;
    void mouseMoveEvent(QMouseEvent*) override;
    void mousePressEvent(QMouseEvent*) override;
    void mouseReleaseEvent(QMouseEvent*) override;

protected:
    int currentPos(const QPoint& pos);                         //获取当前鼠标在第几象限
    void resetColor();                                         //重置所有颜色
    void initPath();                                           //初始化坐标位置path;

protected:
    void drawBackground(QPainter& p);                          //绘制背景
    void drawPie(QPainter& p);                                 //绘制4个扇形区
    void drawCancel(QPainter& p);                              //绘制中央的取消按钮
    void drawArrow(QPainter& p);                               //绘制鼠标箭头
    void drawPath(QPainter& p);
private:
    Ui::MovePanel *ui;

    QVector<QColor>          colors;                           //4个分块的颜色值
    QVector<QPainterPath>    paths;                            //4个分块的rect, 用这4个分块，确认当前鼠标再哪个分组里边
    QPoint                   point;                            //当前鼠标拖动到了哪里
    bool                     isPress{false};                   //是否在中间按下了鼠标

    int                      centerX{0};                       //图形中心X
    int                      centerY{0};                       //图形中心Y
    QRect                    centerRect;                       //图形中心的取消按钮
    int                      alpha{255};                       //透明系数
};
#endif // MOVEPANEL_H
